/**
 */
package mvc_generator.mVCGenerator.impl;

import mvc_generator.mVCGenerator.Condition;
import mvc_generator.mVCGenerator.Expression;
import mvc_generator.mVCGenerator.MVCGeneratorPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Condition</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mvc_generator.mVCGenerator.impl.ConditionImpl#getCondValue <em>Cond Value</em>}</li>
 *   <li>{@link mvc_generator.mVCGenerator.impl.ConditionImpl#getErrorDescription <em>Error Description</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConditionImpl extends MinimalEObjectImpl.Container implements Condition
{
  /**
   * The cached value of the '{@link #getCondValue() <em>Cond Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCondValue()
   * @generated
   * @ordered
   */
  protected Expression condValue;

  /**
   * The default value of the '{@link #getErrorDescription() <em>Error Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getErrorDescription()
   * @generated
   * @ordered
   */
  protected static final String ERROR_DESCRIPTION_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getErrorDescription() <em>Error Description</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getErrorDescription()
   * @generated
   * @ordered
   */
  protected String errorDescription = ERROR_DESCRIPTION_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ConditionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return MVCGeneratorPackage.Literals.CONDITION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Expression getCondValue()
  {
    return condValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetCondValue(Expression newCondValue, NotificationChain msgs)
  {
    Expression oldCondValue = condValue;
    condValue = newCondValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.CONDITION__COND_VALUE, oldCondValue, newCondValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCondValue(Expression newCondValue)
  {
    if (newCondValue != condValue)
    {
      NotificationChain msgs = null;
      if (condValue != null)
        msgs = ((InternalEObject)condValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MVCGeneratorPackage.CONDITION__COND_VALUE, null, msgs);
      if (newCondValue != null)
        msgs = ((InternalEObject)newCondValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MVCGeneratorPackage.CONDITION__COND_VALUE, null, msgs);
      msgs = basicSetCondValue(newCondValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.CONDITION__COND_VALUE, newCondValue, newCondValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getErrorDescription()
  {
    return errorDescription;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setErrorDescription(String newErrorDescription)
  {
    String oldErrorDescription = errorDescription;
    errorDescription = newErrorDescription;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, MVCGeneratorPackage.CONDITION__ERROR_DESCRIPTION, oldErrorDescription, errorDescription));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.CONDITION__COND_VALUE:
        return basicSetCondValue(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.CONDITION__COND_VALUE:
        return getCondValue();
      case MVCGeneratorPackage.CONDITION__ERROR_DESCRIPTION:
        return getErrorDescription();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.CONDITION__COND_VALUE:
        setCondValue((Expression)newValue);
        return;
      case MVCGeneratorPackage.CONDITION__ERROR_DESCRIPTION:
        setErrorDescription((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.CONDITION__COND_VALUE:
        setCondValue((Expression)null);
        return;
      case MVCGeneratorPackage.CONDITION__ERROR_DESCRIPTION:
        setErrorDescription(ERROR_DESCRIPTION_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case MVCGeneratorPackage.CONDITION__COND_VALUE:
        return condValue != null;
      case MVCGeneratorPackage.CONDITION__ERROR_DESCRIPTION:
        return ERROR_DESCRIPTION_EDEFAULT == null ? errorDescription != null : !ERROR_DESCRIPTION_EDEFAULT.equals(errorDescription);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (errorDescription: ");
    result.append(errorDescription);
    result.append(')');
    return result.toString();
  }

} //ConditionImpl
